package com.easybuy.dao.impl;

import java.util.List;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.easybuy.dao.GoodsDao;
import com.easybuy.entity.Goods;

@Repository("goodsDao")
public class GoodsDaoImpl implements GoodsDao {

	@Autowired
	private SqlSessionTemplate sqlSession;

	public void add(Goods goods) {
		sqlSession.getMapper(GoodsDao.class).add(goods);
	}

	public List<Goods> getList(String name, int brandId, int typeId, int first,
			int maxResult) {
		return sqlSession.getMapper(GoodsDao.class).getList(name, brandId,
				typeId, first, maxResult);
	}

	public int getCount(String name, int brandId, int typeId) {
		return sqlSession.getMapper(GoodsDao.class).getCount(name, brandId,
				typeId);
	}

	public List<Goods> getHotGoods(int maxResult) {
		return sqlSession.getMapper(GoodsDao.class).getHotGoods(maxResult);
	}

	public List<Goods> getTypeHotGoods(int typeId, int maxResult) {
		return sqlSession.getMapper(GoodsDao.class).getTypeHotGoods(typeId,
				maxResult);
	}

	public Goods getById(int id) {
		return sqlSession.getMapper(GoodsDao.class).getById(id);
	}
}
